﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.SANY.Util;

namespace PMS.SANY.Entity
{
    /// <summary>
    /// 物料分拣配置
    /// </summary>
    public partial class MaterielSortingConfig : BusEntity
    {
        /// <summary>
        /// 分拣配置名称
        /// </summary>
        public string Name { get; set; }

        /// <summary>
        /// 产品物料规格编码
        /// </summary>
        public string ProductSpecId { set; get; }

        /// <summary>
        /// 分拣物料编号
        /// </summary>
        public string SortingMaterialId { set; get; }

        /// <summary>
        /// 累计抓取次数
        /// </summary>
        public Int16 VaneGrabCount { set; get; }

        /// <summary>
        /// 车型名称电气写入地址(车型名称)
        /// </summary>
        public string CarNameAddress { set; get; }

        /// <summary>
        /// 累计抓取次数电气写入地址
        /// </summary>
        public string VaneGrabCountAddress { set; get; }

        /// <summary>
        /// 启用状态
        /// </summary>
        public bool IsEnabled { set; get; }

        /// <summary>
        /// 分拣说明
        /// </summary>
        public string SortingDesc { set; get; }
    }

    public partial class MaterielSortingConfig : BusEntity
    {
        /// <summary>
        /// 产品物料实体
        /// </summary>
        public MaterielSpec ProductSpec { set; get; }

        /// <summary>
        /// 待分拣物料
        /// </summary>
        public MaterielInfor SortingMaterial { set; get; }

        /// <summary>
        /// 抓取顺序
        /// </summary>
        public List<MaterielSortingSequence> Sequences { set; get; }

        /// <summary>
        /// 料位配置
        /// </summary>
        public List<MaterielSortingLocation> Locations { set; get; }
    }

    /// <summary>
    /// 实体配置
    /// OnModelCreating
    /// </summary>
    public class MaterielSortingConfigTypeConfig : BusEntityTypeConfig<MaterielSortingConfig>, IEntityTypeConfiguration<MaterielSortingConfig>
    {
        public override void Configure(EntityTypeBuilder<MaterielSortingConfig> builder)
        {
            base.Configure(builder);

            #region 主外键关系
            #endregion

            #region 字段属性:最大长度,是否必需,默认值
            builder.Property(p => p.ProductSpecId).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.SortingMaterialId).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.Name).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.VaneGrabCount).IsRequired();
            builder.Property(p => p.CarNameAddress).HasMaxLength(EntityDefinition.DefMiddleColLen).IsRequired();
            builder.Property(p => p.VaneGrabCountAddress).HasMaxLength(EntityDefinition.DefMiddleColLen).IsRequired();
            builder.Property(p => p.IsEnabled).IsRequired();
            #endregion

            #region 备注
            builder.HasComment("MaterielSortingConfig");
            builder.Property(p => p.ProductSpecId).HasComment("产品物料规格编码");
            builder.Property(p => p.SortingMaterialId).HasComment("待分拣物料编号");
            builder.Property(p => p.Name).HasComment("分拣配置名称");
            builder.Property(p => p.VaneGrabCount).HasComment("累计抓取次数");
            builder.Property(p => p.CarNameAddress).HasComment("车型名称电气写入地址");
            builder.Property(p => p.VaneGrabCountAddress).HasComment("累计抓取次数电气写入地址");
            builder.Property(p => p.IsEnabled).HasComment("启用状态");
            builder.Property(p => p.SortingDesc).HasComment("分拣说明");
            #endregion

            #region 种子数据
            //builder.HasData(new MaterielSortingConfig() { Id = "MSC_01", ProductSpecId = "11", SortingMaterialId = "1008", Name = "2350-TG011011", VaneGrabCount = 0, CarNameAddress = "M01_CarName", VaneGrabCountAddress = "M01_VaneGrabCount", IsEnabled = true, CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new MaterielSortingConfig() { Id = "MSC_02", ProductSpecId = "12", SortingMaterialId = "1008", Name = "2280-TG01148", VaneGrabCount = 0, CarNameAddress = "M02_CarName", VaneGrabCountAddress = "M02_VaneGrabCount", IsEnabled = true, CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new MaterielSortingConfig() { Id = "MSC_03", ProductSpecId = "13", SortingMaterialId = "1008", Name = "2280-TG011210", VaneGrabCount = 0, CarNameAddress = "M03_CarName", VaneGrabCountAddress = "M03_VaneGrabCount", IsEnabled = true, CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new MaterielSortingConfig() { Id = "MSC_04", ProductSpecId = "14", SortingMaterialId = "1008", Name = "2280-TG01085", VaneGrabCount = 0, CarNameAddress = "M04_CarName", VaneGrabCountAddress = "M04_VaneGrabCount", IsEnabled = true, CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new MaterielSortingConfig() { Id = "MSC_05", ProductSpecId = "15", SortingMaterialId = "1008", Name = "2280-TG01103", VaneGrabCount = 0, CarNameAddress = "M05_CarName", VaneGrabCountAddress = "M05_VaneGrabCount", IsEnabled = true, CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new MaterielSortingConfig() { Id = "MSC_06", ProductSpecId = "16", SortingMaterialId = "1008", Name = "2240-TG01088", VaneGrabCount = 0, CarNameAddress = "M06_CarName", VaneGrabCountAddress = "M06_VaneGrabCount", IsEnabled = true, CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new MaterielSortingConfig() { Id = "MSC_07", ProductSpecId = "17", SortingMaterialId = "1008", Name = "2240-TG01094", VaneGrabCount = 0, CarNameAddress = "M07_CarName", VaneGrabCountAddress = "M07_VaneGrabCount", IsEnabled = true, CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new MaterielSortingConfig() { Id = "MSC_08", ProductSpecId = "18", SortingMaterialId = "1008", Name = "2240-TG01108", VaneGrabCount = 0, CarNameAddress = "M08_CarName", VaneGrabCountAddress = "M08_VaneGrabCount", IsEnabled = true, CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new MaterielSortingConfig() { Id = "MSC_09", ProductSpecId = "19", SortingMaterialId = "1008", Name = "2350-TG011213", VaneGrabCount = 0, CarNameAddress = "M09_CarName", VaneGrabCountAddress = "M09_VaneGrabCount", IsEnabled = true, CreateUserId = "1", ModifyUserId = "1" });
            //builder.HasData(new MaterielSortingConfig() { Id = "MSC_10", ProductSpecId = "20", SortingMaterialId = "1008", Name = "2240-TG011010", VaneGrabCount = 0, CarNameAddress = "M10_CarName", VaneGrabCountAddress = "M10_VaneGrabCount", IsEnabled = true, CreateUserId = "1", ModifyUserId = "1" });
            #endregion
        }
    }
}
